package controller

import (
	"gitee.com/molonglove/goboot/gin"
	"helper-api/app/models/request"
	"helper-api/app/models/response"
	"helper-api/app/service"
	"net/http"
)

var File = new(FileController)

type FileController struct{}

// FileList 获取文件列表
func (t *FileController) FileList(c *gin.Context) {
	var (
		result    *response.PageData
		param     request.FileListQueryRequest
		customErr *response.BusinessError
		err       error
	)
	if err = c.ShouldBindJSON(&param); err != nil {
		c.JSON(http.StatusOK, response.Fail(response.RequestParamError))
		return
	}
	if result, customErr = service.File.FileList(&param); customErr != nil {
		c.JSON(http.StatusOK, response.ResultCustom(customErr))
		return
	}
	c.JSON(http.StatusOK, response.Ok(result))
}

// FileSize 获取文件大小
func (t *FileController) FileSize(c *gin.Context) {

}

// FileCreate 文件创建
func (t *FileController) FileCreate(c *gin.Context) {
	var (
		param     request.ToolsFileCreateRequest
		customErr *response.BusinessError
		err       error
	)
	if err = c.ShouldBindJSON(&param); err != nil {
		c.JSON(http.StatusOK, response.Fail(response.Menus[response.RequestParamError]))
		return
	}
	if customErr = service.File.FileCreate(&param); err != nil {
		c.JSON(http.StatusOK, response.ResultCustom(customErr))
		return
	}
	c.JSON(http.StatusOK, response.Ok("创建成功"))
}

func (t *FileController) FileRename(c *gin.Context) {

}

func (t *FileController) FilePermission(c *gin.Context) {

}

func (t *FileController) FileDelete(c *gin.Context) {

}

func (t *FileController) FileCompress(c *gin.Context) {

}

func (t *FileController) FileUncompress(c *gin.Context) {

}

func (t *FileController) FileCopy(c *gin.Context) {

}

func (t *FileController) FileRemoteDownload(c *gin.Context) {

}

func (t *FileController) FileOpen(c *gin.Context) {

}

func (t *FileController) FileDownload(c *gin.Context) {

}

func (t *FileController) FileUploading(c *gin.Context) {

}
